<template>
	<view class="container">
		<l-file ref="lFile" @up-success="upSuccess"></l-file>
		<view class="top">
			<view class="tdmc u-border-bottom u-m-l-30">
				<text>团队名称</text>
				<text class="right">{{ model.name }}</text>
			</view>
			<view class="tdmc u-border-bottom u-m-l-30">
				<text>团队类型</text>
				<text class="right" v-if="model.demand != undefined">{{ model.demand.teamType }}</text>
			</view>
			<view class="tdmc u-border-bottom u-m-l-30">
				<text>擅长领域</text>
				<text class="right">
					<block v-for="(item, index) in model.intention" :key="'i'+index">{{ item.enterpriseField }}{{ item.expertise }}</block>
				</text>
			</view>
			<view class="tdmc u-border-bottom u-m-l-30">
				<text>保证金金额</text>
				<text class="right">{{ model.demand && model.demand.integrityDeposit ? '￥' + model.demand.integrityDeposit : '无' }}</text>
			</view>
			<view class="fgx"></view>
		</view>
		<view class="u-m-t-30">
			<view class="u-flex u-row-between tdcy" @click="selectShow(0)">
				<view class="u-font-30 u-m-l-30" style="font-weight: bold;">团队成员</view>
				<view class="u-flex u-row-center u-m-r-30" style="margin-left: auto;">
					<text class="u-font-30" style="color: #AB61FF;" v-if="model.users != undefined">{{ model.users.length }}个</text>
				</view>
				<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(0, true)" v-if="!flagList[0]"></u-icon>
				<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(0, false)" v-if="flagList[0]"></u-icon>
			</view>
			<u-read-more :toggle="toggle" :show-height="showHeight" ref="uReadMore" closeText="收起" open-text="查看全部">
				<view v-for="(item, index) in model.users"
					:key="'u'+index">
				<view
					class="f-list u-row-between u-border-bottom u-flex u-m-r-20 u-m-l-20 u-p-t-20 u-p-b-20"
					
					v-show="flagList[0]"
					@click="showChildren(index)"
				>
					<block v-if="item.id != $store.state.userInfo.id">
						<view class="u-flex">
							<view class="qylg" :style="{ backgroundImage: 'url(' + logoMask + ')' }">
								<text class="u-line-2">{{ item.username }}</text>
							</view>
							<view class="f-item u-m-l-32">
								<view class="title u-flex u-row-between">
									<view class="">
										<text class="name">{{ item.username }}</text>
										<text v-if="item.leader" class="tz">团长</text>
										<text v-if="item.type == 10" class="td">团队</text>
									</view>
									<view class="bzj" v-if="item.bond">
										<text>￥{{ item.bond }}</text>
									</view>
								</view>
								<view class="explain" v-if="item.bond === null">未交保证金</view>
								<view class="explain" v-if="item.type == 10 && item.children.length">团队成员{{item.children.length}}人</view>
								
							</view>
						</view>
						<u-icon name="arrow-down" style="margin-right: 20upx;" v-if="item.type == 10 && !item.show"></u-icon>
						<u-icon name="arrow-up" style="margin-right: 20upx;"  v-if="item.type == 10 && item.show"></u-icon>
					</block>
					<block v-else>
						<view class="u-flex">
							<view class="qylg" :style="{ backgroundImage: 'url(' + logoMask + ')' }">
								<text class="u-line-2">{{ item.username }}</text>
							</view>
							<view class="f-item u-m-l-32">
								<view class="title u-flex-col">
									<view class="">
										<text class="name">{{ item.username }}</text>
										<text v-if="item.leader" class="tz">团长</text>
										
									</view>
									<view class="explain" v-if="item.bond === null">未交保证金</view>
								</view>
							</view>
						</view>
						<view class="scxy u-flex u-row-center" v-if="!item.bond && model.demand && model.demand.integrityDeposit" @click="pay">缴纳保证金</view>
					</block>
					</view>
					<view class="u-p-20 team-bg" v-if="item.show && item.children && item.children.length">
						<view
							class="f-list u-row-between u-border-bottom u-flex u-m-r-20 u-m-l-20 u-p-t-20 u-p-b-20" v-for="(v, t) in item.children" :key="'c' + t">
						<view  class="u-flex">
							<view class="qylg" :style="{ backgroundImage: 'url(' + logoMask + ')' }">
								<text class="u-line-2">{{ v.name }}</text>
							</view>
							<view class="f-item u-m-l-32">
								<view class="title u-flex-col">
									<view class="">
										<text class="name">{{ v.name }}</text>
										<text v-if="v.leader" class="tz">团长</text>
									</view>
									<view class="explain" v-if="v.bond === null">未交保证金</view>
								</view>
							</view>
						</view>
							<view class="scxy u-flex u-row-center" v-if="isNeedPay(v.bond) && v.id == $store.state.userInfo.id" @click="needPay(v.bond)">补缴保证金</view>
						</view>
					</view>
				</view>
			</u-read-more>
			<!-- <view class="ckqb">
				<text>查看全部</text>
				<image style="height: 14rpx; width: 14rpx;margin-left:20rpx;" src="../../../static/img/cxx.png" mode=""></image>
			</view> -->
			<!-- <view class="u-flex u-row-between u-m-t-30 u-m-r-30">
				<view @click="tohomepage" class="xmkk" v-for="(item,index) in 5" :key="index" :style="{ backgroundImage: 'url(' + bjxm + ')' }">
					<text>姓名</text>
				</view>
			</view> -->
		</view>
		<view class="fgx u-m-t-30"></view>
		<u-read-more :toggle="toggle" show-height="680" ref="uReadMore" closeText="收起" open-text="查看全部" :shadowStyle="{ backgroundImage: '' }">
			<view class="u-m-l-30 u-m-t-20" @click="selectShow(1)">
				<view class="u-font-30 xmfp u-flex u-row-between">
					项目分配
					<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(1, true)" v-if="!flagList[1]"></u-icon>
					<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(1, false)" v-if="flagList[1]"></u-icon>
				</view>
				
				<view class="u-m-t-22" v-for="(item, index) in model.teamProject" :key="'t'+index" v-show="flagList[1]">
					<project-allocation @click="saveProporte" :checkLeader="checkLeader"  :item="item"></project-allocation>
				</view>
					<!--<view class="">
						<view class="u-flex u-row-between u-m-l-30 u-m-r-30 u-p-t-20">
							<text>{{ item.project.name }}</text>
							<image @click="toProjectAllocation" style="width: 48rpx; height: 48rpx;" src="../../../static/register/xy.png" mode=""></image>
						</view>
						<view class="xhx"></view>
						<view class="f-list u-flex u-p-b-20 u-p-t-20" v-for="(xitem, xindex) in item.projectUser" :key="xindex">
							<view class="qylg" :style="{ backgroundImage: 'url(' + logoMask + ')' }">
								<text class="u-line-2">{{ xitem.username }}</text>
								<text v-if="xitem.leader" class="tz" style="padding: 3 10upx;">团长</text>
							</view>
							<view class="f-item u-flex u-m-l-32" style="flex-direction: column;">
								<view class="title u-flex u-m-t-12">
										<view class="fpbl u-m-r-40 u-m-b-20">
											<text>分配比例</text>
											<u-input  class="fpblsz" v-model="xitem.proportion" />
											<text class="bfh">%</text>
										</view>
										<view class="fpbl">
											<text>项目保证金</text>
											<u-input class="fpblsz" v-model="xitem.bond" />
											<text class="bfh">元</text>
										</view>
								</view>
								<u-input class="fpblsz" style="display: inline-block;width: 250upx;height:150rpx;" type="textarea" v-model="xitem.remark" placeholder="分配描述" />
							</view>
						</view>
					</view>
					<view class="caozuo u-flex u-row-around" v-if="tbIndex === index">
						<button class="baocun" @click="handleClickItemSave(item)">保存</button>
						<button class="quxiao">取消</button>
					</view>
				</view> -->

				<!-- <view class="ckqb">
				<text>收起</text>
				<image style="height: 14rpx; width: 24rpx;" src="../../../static/img/cxs.png" mode=""></image>
			</view> -->
			</view>
		</u-read-more>
		<view class="fgx u-m-t-30"></view>
		<view class="middle-tdxy" style="overflow: hidden;">
			<view class=" u-flex u-row-between u-m-l-30 u-m-t-30" @click="selectShow(2)">
				<view class="u-font-30 xmfp">团队协议</view>
				<view class="u-flex u-col-center">
					<view class="scxy" style="margin-right: 30upx;" v-show="show">
						<image style="" src="../../../static/img/jh.png" mode=""></image>
						<text @click="onUpload(true)">上传协议</text>
					</view>
					<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(2, true)" v-if="!flagList[2]"></u-icon>
					<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(2, false)" v-if="flagList[2]"></u-icon>
				</view>
			</view>

			<view v-for="(item, index) in model.fileAgrees" :key="'f'+index" class="tdxy u-m-l-30 u-m-t-30" @click="loadFile(item.path)" v-if="flagList[2]">
				<view class="word u-m-l-30 u-m-r-30 u-p-t-30">
					<image src="../../../static/img/word.png" mode=""></image>
					<text class="u-line-1">{{ item.oldName }}</text>
				</view>
				<view class="sctime u-m-l-30 u-m-r-30 u-p-t-30 u-flex u-row-between">
					<view class="u-flex">
						<text class="scsj">上传时间:</text>
						<text class="sctime">{{ item.uploadTime }}</text>
					</view>
					<view v-if="$store.state.userInfo.id == item.userId" @click="delFile(item.id)">删除</view>
				</view>
			</view>
		</view>
		<view class="fgx u-m-t-30"></view>
		<view class="middle-hyjy u-m-t-30">
			<view class=" u-flex u-row-between u-m-l-30 " @click="selectShow(3)">
				<view class="u-font-30 xmfp">会议纪要</view>
				<view class="u-flex u-col-center">
					<view @click="tonewSummary(id)" v-show="show" class="scxy" style="margin-right: 30upx;">
						<image style="" src="../../../static/img/jh.png" mode=""></image>
						<text>新增纪要</text>
					</view>
					<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(3, true)" v-if="!flagList[3]"></u-icon>
					<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(3, false)" v-if="flagList[3]"></u-icon>
				</view>
			</view>
			<view class="xhx" v-show="flagList[3]"></view>

			<view class="uni-padding-wrap uni-common-mt" v-show="flagList[3]">
				<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
					<swiper-item v-for="(item, index) in model.notepadRecords" :key="'n'+index">
						<view class="u-m-l-30">
							<view class="u-flex u-m-t-35">
								<view class="ty"></view>
								<text class="xmjz">{{ item.title }}</text>
								<text class="sctime" v-if="item.createTime != undefined">{{ item.createTime.substr(0, 10) }}</text>
							</view>
							<view class="u-flex">
								<view class="xx"></view>
								<view style="width: 100%;">
									<view class="zxjz u-m-t-15  u-m-b-15">{{ item.content }}</view>
									<view class="u-flex" v-if="item.imgUrl != undefined">
										<view class="tp" v-for="(xitem, xindex) in item.imgUrl.split(',')" :key="xindex">
											<image @tap="previewImageStr(xindex, item.imgUrl)" :src="getImgUrl(xitem)" style="width: 100%;height: 100%;"></image>
										</view>
									</view>
									<view class="u-m-l-30 u-m-t-20 u-flex u-row-between u-col-center">
										<view class="u-flex u-col-center">
											<view class="tyqk">团员确认情况</view>
											<view class="hekuai" v-if="item.read != null">{{ item.read.length }}/{{ item.read.length + item.unread.length }}</view>
											<view class="hekuai" v-else>0/0</view>
											<view class="u-m-l-30" v-if="$store.state.userInfo.id == item.createUserId" @click="delSummary(item.id)">删除</view>
										</view>
										<view class="u-m-r-30"><image @click="toConfirmation(item)" class="sd" src="../../../static/img/sd.png" mode=""></image></view>
									</view>
								</view>
							</view>
						</view>
					</swiper-item>
				</swiper>
			</view>
			<view class="fgx u-m-t-30"></view>
		</view>
		<view class="u-m-l-30 u-m-t-30">
			<view class="u-flex u-row-between tdcy" @click="selectShow(4)">
				<view class="u-font-30" style="font-weight: bold;">N+1企业</view>
				<view class="u-flex u-row-center">
					<text class="u-font-30 u-m-r-30" style="color: #AB61FF;" v-if="model.companys != undefined">{{ model.companys.length }}个</text>
					<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(4, true)" v-if="!flagList[4]"></u-icon>
					<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(4, false)" v-if="flagList[4]"></u-icon>
				</view>
			</view>
			<view class="u-flex u-row-between u-m-t-30" v-if="flagList[4]">
				<view @click="toteamPage" class="qymc u-line-1" v-for="(item, index) in model.companys" :key="'com'+index" :style="{ backgroundImage: 'url(' + bjxm + ')' }">
					<text>{{ item.name }}</text>
				</view>
			</view>
		</view>
		<view class="fgx u-m-t-30"></view>
		<view class=" u-m-t-30">
			<view class="u-flex u-row-between tdcy" @click="selectShow(6)">
				<view class="u-font-30 u-m-l-30" style="font-weight: bold;">课程(0/{{ courses && courses.length ? courses.length : 0 }})</view>
				<view class="u-flex u-row-center">
					<view @click="toChoice(id)" class="scxy" style="margin-right: 30upx;">
						<image style="" src="../../../static/img/jh.png" mode=""></image>
						<text>选择课程</text>
					</view>
					<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(6, true)" v-if="!flagList[6]"></u-icon>
					<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(6, false)" v-if="flagList[6]"></u-icon>
				</view>
			</view>
			<view class="u-m-t-30" v-if="flagList[6]">
				<block v-for="(item, index) in courses" :key="item.id">
					<u-swipe-action
						:show="item.show"
						:index="index"
						v-if="$store.state.userInfo.id != item.selectCourseUserId"
						@click="delCourse"
						@open="open"
						:options="options"
						style="width: 100%;"
						class="u-m-b-20"
					>
						<view class="u-p-20" style="width:90%;margin:0 auto;background: #F5F5F9;" @click="toCourse(item.id)">
							<view class="u-flex u-p-b-10">
								<view style="width: 200rpx;">
									<image src="../../../static/img/icon_kc.png" style="width:25rpx;height: 26rpx;margin-right:15rpx;" />
									<text>课程名称</text>
								</view>
								<view style="flex:1;display: flex;justify-content: space-between;align-items: center;">
									<text>{{ item.name }}</text>
									<image src="../../../static/img/more_gray.png" style="width: 48rpx;height:48rpx;" />
								</view>
							</view>
							<view class="u-flex">
								<view style="width: 200rpx;">
									<image src="../../../static/img/icon_ds.png" style="width:25rpx;height: 26rpx;margin-right:15rpx;" />
									<text>导师名称</text>
								</view>
								<text>{{ item.teacherName }}</text>
								<image src="../../../static/img/more_gray.png" style="width: 48rpx;height:48rpx;visibility: hidden;" />
							</view>
						</view>
					</u-swipe-action>
					<view v-else class="u-p-20" style="width:90%;margin:0 auto;background: #F5F5F9;" @click="toCourse(item.id)">
						<view class="u-flex u-p-b-10">
							<view style="width: 200rpx;">
								<image src="../../../static/img/icon_kc.png" style="width:25rpx;height: 26rpx;margin-right:15rpx;" />
								<text>课程名称</text>
							</view>
							<view style="flex:1;display: flex;justify-content: space-between;align-items: center;">
								<text>{{ item.name }}</text>
								<image src="../../../static/img/more_gray.png" style="width: 48rpx;height:48rpx;" />
							</view>
						</view>
						<view class="u-flex">
							<view style="width: 200rpx;">
								<image src="../../../static/img/icon_ds.png" style="width:25rpx;height: 26rpx;margin-right:15rpx;" />
								<text>导师名称</text>
							</view>
							<text>{{ item.teacherName }}</text>
							<image src="../../../static/img/more_gray.png" style="width: 48rpx;height:48rpx;visibility: hidden;" />
						</view>
					</view>
				</block>
			</view>
		</view>
		<view class="fgx u-m-t-30"></view>
		<view class="u-m-l-30 u-m-t-30">
			<view class="u-flex u-row-between tdcy" @click="selectShow(5)">
				<view class="u-font-30" style="font-weight: bold;">文件</view>
				<view class="u-flex u-col-center">
					<view class="sc" style="margin-right: 30upx;" v-show="show">
						<image style="" src="../../../static/img/jh.png" mode=""></image>
						<text @click="onUpload(false)">上传</text>
					</view>
					<u-icon name="arrow-down" style="margin-right: 20upx;" @click="selectShow(5, true)" v-if="!flagList[5]"></u-icon>
					<u-icon name="arrow-up" style="margin-right: 20upx;" @click="selectShow(5, false)" v-if="flagList[5]"></u-icon>
				</view>
			</view>
		</view>
		<view class=" u-p-t-20 u-p-b-20" v-if="flagList[5]">
			<block v-for="(item, index) in model.files" :key="item.id">
				<u-swipe-action
					:show="item.show"
					:index="index"
					v-if="$store.state.userInfo.id == item.userId"
					@click="delFiles"
					@open="openFiles"
					:options="options"
					style="width: 100%;"
				>
					<view class="f-list u-flex u-p-t-20 u-p-b-20 u-col-center" style="display: flex;justify-content: space-between;">
						<view class="qylg"><image style="width: 64rpx; height: 64rpx;" src="../../../static/img/file.png" mode=""></image></view>
						<view class="f-item" style="flex: 1;" @click="onOpenDoc(item.path)">
							<view class="u-font-34">
								<text style="display:block;width:400rpx;" class="u-line-1">{{ item.oldName }}</text>
							</view>
							<view class="title u-flex u-m-t-12" style="width: 80%;">
								<text class="name">{{ item.userName }}</text>
								<view class="u-flex u-row-between" style="width: 100%;">
									<text class="rq">{{ item.uploadTime.substr(0, 10) }}</text>
									<text class="wjdx">{{ item.size / 1000 + 'KB' }}</text>
								</view>
							</view>
						</view>
						<view class="xz" @click="onDown(item.path)" style="margin-right: 20upx;">下载</view>
					</view>
				</u-swipe-action>
				<view class="f-list u-flex u-p-t-20 u-p-b-20 u-col-center" v-else style="display: flex;justify-content: space-between;">
					<view class="qylg "><image style="width: 64rpx; height: 64rpx;" src="../../../static/img/file.png" mode=""></image></view>
					<view class="f-item " style="flex: 1;" @click="onOpenDoc(item.path)">
						<view class="u-font-34">
							<text style="display:block;width:400rpx;" class="u-line-1">{{ item.oldName }}</text>
						</view>
						<view class="title u-flex u-m-t-12" style="width: 80%;">
							<text class="name">{{ item.userName }}</text>
							<view class="u-flex u-row-between" style="width: 100%;">
								<text class="rq">{{ item.uploadTime.substr(0, 10) }}</text>
								<text class="wjdx">{{ item.size / 1000 + 'KB' }}</text>
							</view>
						</view>
					</view>
					<view class="xz" @click="onDown(item.path)" style="margin-right: 20upx;">下载</view>
				</view>
			</block>
		</view>
		<view style="height:30rpx;"></view>
	</view>
</template>

<script>
import lFile from '@/components/l-file/l-file.vue'
export default {
	components: { lFile },
	data() {
		return {
			type:1,
			myblod: false,
			options: [
				{
					text: '删除',
					style: {
						backgroundColor: '#dd524d'
					}
				}
			],
			localPath: '',
			baseUrl: this.$mConfig.baseUrl,
			indicatorDots: true,
			autoplay: false,
			interval: 2000,
			duration: 500,
			flagList: [false, false, false, false, false, false],
			tbIndex: -1,
			id: 0,
			toggle: false,
			showHeight: 300,
			logoMask: this.$mAssetsPath.logoMask,
			bjxm: '../../static/homepage/xmkk.png',
			filelist: [],
			xmlist: [],
			list: [],
			model: {
				companys: [],
				fileAgrees: [],
				files: [],
				notepadRecords: [],
				team: {},
				teamProjects: [],
				demand: [],
				intention: []
			},
			isLeader: false,
			userId: '',
			show: true,
			courses: [],
			checkLeader: false,
			syncCourse: {
				id: '',
				userId: '',
				type: 1
			}
		}
	},
	onNavigationBarButtonTap(e) {
		uni.switchTab({
			url: '../tabBar/message'
		})
		return
	},
	onLoad(options) {
		console.log(options)
		if (options.id) {
			this.id = options.id
			this.syncCourse.id = options.id
		}
		if (options.userId) {
			this.userId = options.userId
			this.syncCourse.userId = options.userId
		}
		if (options.teamChatId) {
			this.teamChatId = options.teamChatId
			this.showcheckLeader()
		}
		uni.setStorageSync('syncCourse', this.syncCourse)
	},
	onShow() {
		this.initPage(this.id)
		this.listAddedCourse()
		this.getcheckLeader()
	},
	methods: {
		async saveProporte(item){
			let project=item.model.project,projectUser = item.model.projectUser;
			let arr = [];
			for(var i in projectUser){
				arr.push({
					"businessId": project.id,
					"id":projectUser[i].id,
					"leader": projectUser[i].leader,
					"proporeTarget": projectUser[i].userId,
					"proportion": projectUser[i].proportion,
					"remark": projectUser[i].remark,
					"teamChatId": this.teamChatId,
					"balance": projectUser[i].balance,
					"type": project.type
				})
			}
			//this.saveProjectProporte(arr);
			let {code} = await this.$apis.saveProjectProporte(arr);
		},
		isNeedPay(val){
			if(!val) val= 0;
			if(this.model.demand.integrityDeposit){
				let money = parseFloat(this.model.demand.integrityDeposit) - parseFloat(val)
				if(money > 0){
					return true
				}else{
					return false
				}
			}else{
				return false
			}
		},
		async fetchGroupPersonBond(reqBody, index) {
			console.log('index', index)
			let { data } = await this.$apis.fetchGroupPersonBond(reqBody)
			let users = this.model.users[index] ? this.model.users[index] : []
			users.children = data
			users.show = !users.show
			this.model.users[index] = users
		
			console.log(this.model.users)
			this.$forceUpdate()
		},		
		async pay() {
			var payData = { payMoney: this.model.demand.integrityDeposit, type: 1, id: this.id }
			let { data, code } = await this.$apis.createTeamPayBond(payData)
			console.log('createTeamPayBond', data)
			if (code == 200) {
				this.$mRouter.push({
					route: this.$mRoutesConfig.pay,
					query: {
						datas: JSON.stringify(data)
					}
				})
			}
		},
		async needPay(val) {
			var payMoney = this.model.demand.integrityDeposit;
			if(!val) val= 0;
			if(this.model.demand.integrityDeposit){
				payMoney = parseFloat(this.model.demand.integrityDeposit) - parseFloat(val)
			}
			var payData = { payMoney: payMoney, type: 1, id: this.id }
			let { data, code } = await this.$apis.createTeamPayBond(payData)
			console.log('createTeamPayBond', data)
				data.name = this.model.name;
			if (code == 200) {
				this.$mRouter.push({
					route: this.$mRoutesConfig.pay,
					query: {
						datas: JSON.stringify(data)
					}
				})
			}
		},
		showChildren(index) {
			let users = this.model.users
			if (users && users[index] && users[index].type == 10) {
				var fromTeamId = users[index].fromTeamId.split('_')
				console.log('fromTeamId', fromTeamId)
				if (fromTeamId.length && fromTeamId[1] > 0) {
					let reqBody = {
						id: fromTeamId[1],
						type: 1
					}
					this.fetchGroupPersonBond(reqBody, index)
				}
			}
		},		
		async getcheckLeader() {
			let result = await this.$apis.checkLeader({ teamChatId: 'team_' + this.id })
			this.checkLeader = result.data
		},
		delCourse(id) {
			var that = this
			uni.showModal({
				content: '删除该课程',
				success(res) {
					if (res.confirm) that.deleteUserCourse(id)
				}
			})
		},
		async deleteUserCourse(index) {
			let { code } = await this.$apis.deleteUserCourse({ id: this.courses[index].selectDataId })
			if (code == 200) {
				this.courses.splice(index, 1)
			}
		},
		// 如果打开一个的时候，不需要关闭其他，则无需实现本方法
		open(index) {
			console.log('open', index)
			// 先将正在被操作的swipeAction标记为打开状态，否则由于props的特性限制，
			// 原本为'false'，再次设置为'false'会无效
			this.courses[index].show = true
			this.courses.map((val, idx) => {
				if (index != idx) this.courses[idx].show = false
			})
		},
		delFiles(index) {
			var that = this
			uni.showModal({
				content: '删除该文件',
				success(res) {
					if (res.confirm) that.deleteFileAgrees(index)
				}
			})
		},
		async deleteFileAgrees(index) {
			let { code } = await this.$apis.deleteFileAgree({ id: this.model.files[index].id })
			if (code == 200) {
				this.model.files.splice(index, 1)
			}
		},
		// 如果打开一个的时候，不需要关闭其他，则无需实现本方法
		openFiles(index) {
			console.log('open', index)
			// 先将正在被操作的swipeAction标记为打开状态，否则由于props的特性限制，
			// 原本为'false'，再次设置为'false'会无效
			this.model.files[index].show = true
			this.model.files.map((val, idx) => {
				if (index != idx) this.model.files[idx].show = false
			})
		},
		delFile(id) {
			var that = this
			uni.showModal({
				content: '删除该文件',
				success(res) {
					if (res.confirm) that.deleteFileAgree(id)
				}
			})
		},
		async deleteFileAgree(id) {
			let { code } = await this.$apis.deleteFileAgree({ id: id })
			if (code == 200) {
				this.initPage(this.id)
			}
		},
		delSummary(id) {
			var that = this
			uni.showModal({
				content: '删除该纪要',
				success(res) {
					if (res.confirm) that.deleteNotepadRecord(id)
				}
			})
		},
		async deleteNotepadRecord(id) {
			let { code } = await this.$apis.deleteNotepadRecord({ id: id })
			if (code == 200) {
				this.initPage(this.id)
			}
		},
		toCourse(id) {
			uni.navigateTo({
				url: '/pages/classroom/detail?id=' + id
			})
		},
		async listAddedCourse() {
			let body = {}
			console.log('userId', this.userId)
			if (this.userId) {
				if (!this.checkLeader) this.teamUserId = this.$store.state.userInfo.id
				body = {
					privateUserId: this.checkLeader ? this.$store.state.userInfo.id : this.userId,
					groupId: this.id,
					type: 1
				}
			} else {
				body = {
					groupId: this.id,
					type: 1
				}
			}
			let { data } = await this.$apis.listAddedCourse(body)
			var arr = []
			data &&
				data.forEach(function(item, index) {
					item.show = false
					arr.push(item)
				})
			this.courses = arr
		},
		async showcheckLeader() {
			let result = await this.$apis.checkLeader({ teamChatId: this.teamChatId })
			this.isLeader = result.data
			if (!this.isLeader && this.userId != '') {
				this.show = false
				this.syncCourse.isLeader = false
			} else {
				this.syncCourse.isLeader = true
			}
			uni.setStorageSync('syncCourse', this.syncCourse)
		},
		previewImageStr(index, files) {
			//预览图片
			let imgs = []
			if (files.indexOf(',') == -1) {
				imgs = [files]
			} else {
				imgs = files.split(',')
			}
			let urls = []
			for (var i in imgs) {
				urls.push(this.$mConfig.baseUrl + imgs[i])
			}
			console.log(urls)
			uni.previewImage({
				current: index,
				urls: urls
			})
		},
		selectShow(index, flag) {
			console.log('show')
			this.flagList[index] = !this.flagList[index]
			this.initPage(this.id)
		},
		getImgUrl(url) {
			return this.$mConfig.baseUrl + url
		},
		scroll(event) {
			//距离每个边界距离
			console.log(event.detail)
		},
		//滚动到底部/右边触发
		scrolltolower() {
			console.log(1111)
		},
		// 滚动到顶部/左边触发
		scrolltoupper() {
			console.log(2222)
		},
		downloadFile(url) {
			uni.downloadFile({
				url: this.$mConfig.baseUrl + url, //仅为示例，并非真实的资源
				success: data => {
					if (data.statusCode === 200) {
						//文件保存到本地
						uni.saveFile({
							tempFilePath: data.tempFilePath, //临时路径
							success: function(res) {
								uni.showToast({
									icon: 'none',
									mask: true,
									title: '文件已保存：' + res.savedFilePath, //保存路径
									duration: 3000
								})
								setTimeout(() => {
									//打开文档查看
									uni.openDocument({
										filePath: res.savedFilePath,
										success: function(res) {
											// console.log('打开文档成功');
										}
									})
								}, 3000)
							}
						})
					}
				}
			})
		},
		async handleClickItemSave(item) {
			console.log(item)
			let obj = {
				businessId: '',
				proporte: '',
				remark: ''
			}
			obj.projectId = item.id
			obj.teamId = this.model.team.id
			item.projectUsers.forEach(function(ele) {
				obj.businessId = obj.businessId + ele.id + ','
				obj.proporte = obj.proporte + ele.proportion + ','
				obj.remark = obj.remark + ele.remark + '@'
			})
			obj.businessId = obj.businessId.substr(0, obj.businessId.length - 1)
			obj.proporte = obj.proporte.substr(0, obj.proporte.length - 1)
			obj.remark = obj.remark.substr(0, obj.remark.length - 1)
			let data = await this.$apis.saveProjectProporte(obj)
			if (data.code === 200) {
				this.tbIndex = -1
				this.initPage(this.id)
			}
			console.log(obj)
		},
		handleClickItem(index) {
			this.tbIndex = index
		},
		onOpenDoc(file) {
			let url = this.$mConfig.baseUrl + file
			/* 下载返回临时路径（退出应用失效） */
			this.$refs.lFile.download(url).then(path => {
				/* 预览 */
				this.$refs.lFile.open(path)
			})
		},
		/* 保存 */
		onDown(file) {
			let url = this.$mConfig.baseUrl + file
			this.$refs.lFile.download(url, 'local').then(path => {
				this.localPath = path
			})
		},
		/* 上传 */
		onUpload(flag) {
			this.$refs.lFile.upload({
				// #ifdef APP-PLUS
				// nvue页面使用时请查阅nvue获取当前webview的api，当前示例为vue窗口
				currentWebview: this.$mp.page.$getAppWebview(),
				// #endif
				//非真实地址，记得更换,调试时ios有跨域，需要后端开启跨域并且接口地址不要使用http://localhost/
				url: this.$mConfig.baseUrl + '/notepad/saveFile',
				//默认file,上传文件的key
				name: 'file',
				// header: {'Authorization':'token'},
				//...其他参数
				formData: {
					businessId: this.id,
					isAgree: flag,
					type: 1,
					userId: this.userId
				},
				header: {
					'X-requested-With': 'XMLHttpRequest',
					'ZC-TOKEN': uni.getStorageSync('token')
				}
			})
		},
		upSuccess(res) {
			this.initPage(this.id)
		},
		loadFile(file) {
			uni.downloadFile({
				url: this.$mConfig.baseUrl + file,
				success: function(res) {
					var filePath = res.tempFilePath
					uni.openDocument({
						filePath: filePath,
						success: function(res) {
							console.log('打开文档成功')
						}
					})
				}
			})
		},
		async initPage(id) {
			var that = this
			let reqBody = {
				id: id,
				type: 1
			}
			if (this.userId != '') reqBody['userId'] = this.userId
			let result = await this.$apis.summary(reqBody)
			this.model = result.data
			var users = []
			if (this.model.demand && this.model.demand.integrityDeposit) {
				for (var i in this.model.users) {
					users[i] = this.model.users[i]
					users[i].children = []					
					users[i].show = false
					if (this.model.users[i].blod && this.model.users[i].id == that.$store.state.userInfo.id) {
						that.myblod = this.model.users[i].blod
					}
				}
			} else {
				for (var i in this.model.users) {
					users[i] = this.model.users[i]
					users[i].children = []			
					users[i].show = false
				}
			}
			this.model.users = users
			console.log(this.model.users)
		},
		toTeamMembers() {
			let param = ''
			if (this.userId != '') param = '?userId=' + this.userId
			uni.navigateTo({
				url: '../../notepad/zhihuiTeam/teamMembers' + param
			})
		},
		toProjectAllocation() {
			let param = ''
			if (this.userId != '') param = '?userId=' + this.userId
			uni.navigateTo({
				url: '../../notepad/zhihuiTeam/projectAllocationDetails' + param
			})
		},
		tohomepage() {
			uni.navigateTo({
				url: '../../homepage/homepage'
			})
		},
		toteamPage() {
			uni.navigateTo({
				url: '../../homepage/teamPage'
			})
		},
		tonewSummary(id) {
			let param = ''
			if (this.userId != '') param = '&userId=' + this.userId
			uni.navigateTo({
				url: '../../notepad/zhihuiTeam/newSummary?&type=1&id=' + id + param
			})
		},
		toChoice(id) {
			if (this.checkLeader) {
				let param = ''
				if (this.userId != '') param = '&userId=' + this.userId
				uni.navigateTo({
					url: '../../classroom/choice?type=1&id=' + id + param
				})
			} else {
				uni.showToast({
					title: '只有团长可以选择课程！',
					icon: 'none'
				})
			}
		},
		toConfirmation(item) {
			uni.navigateTo({
				url: '../../notepad/zhihuiTeam/confirmation?id='+item.id
			})
		},
		toMinutesOfMeeting() {
			let param = ''
			if (this.userId != '') param = '?userId=' + this.userId
			uni.navigateTo({
				url: '../../notepad/zhihuiTeam/minutesOfMeeting' + param
			})
		},
		toFile() {
			let param = ''
			if (this.userId != '') param = '?userId=' + this.userId
			uni.navigateTo({
				url: '../../notepad/zhihuiTeam/file' + param
			})
		}
	}
}
</script>
<style>
page {
	background-color: #f5f5f9;
}
</style>
<style scoped lang="scss">
.container {
	background-color: #fff;
}
.tdmc {
	line-height: 100rpx;
	width: 90%;
	margin-left: 5%;

	text {
		font-size: 30rpx;
		color: #0d1d36;
	}

	.right {
		position: absolute;
		left: 228rpx;
	}

	.jine {
		position: absolute;
		left: 228rpx;
		font-size: 30rpx;
		color: #ab61ff;
	}
}

.fgx {
	width: 100%;
	height: 20rpx;
	background-color: #f5f5f9;
}

.xmkk {
	width: 102rpx;
	height: 118rpx;
	background-repeat: no-repeat;
	background-size: 100% auto;
	background-position: 0 bottom;

	text {
		color: #888d99;
		font-size: 26rpx;
		line-height: 118rpx;
		margin-left: 27rpx;
	}
}

.xmfp {
	color: #0d1d36;
	font-weight: bold;
}

.xmfpxj {
	width: 690rpx;
	background: #f5f5f9;
	border-radius: 10rpx;

	.tubiao {
		color: #0d1d36;
		font-size: 30rpx;
	}

	.xhx {
		width: 100%;
		height: 1rpx;
		background-color: #cacedb;
		margin-top: 20rpx;
	}
}

.file-name {
	width: 102rpx;
	height: 118rpx;
	background-size: 100% auto;
	background-position: 0 bottom;
	overflow: hidden;
	text-align: center;

	text {
		color: #888d99;
		font-size: 26rpx;
	}
}

.title {
	display: flex;
	justify-content: space-between;
	padding-right: 40rpx;
}

.tz {
	width: 68rpx;
	color: #ffffff;
	font-size: 24rpx;
	height: 36rpx;
	background: #ab61ff;
	border-radius: 6rpx;
	margin-left: 20rpx;
}

.name {
	font-size: 30rpx;
	color: #0d1d36;
	font-weight: bold;
}

.explain {
	color: #888d99;
	font-size: 26rpx;
}

.fpblsz {
	display: flex;
	justify-content: center;
	align-items: center;
	border: 2rpx solid #4b9cff;
	margin-left: 10rpx;
	padding: 10upx;
}

.fpbl {
	display: flex;
	text {
		font-size: 24rpx;
		color: #4b9cff;
	}

	.fpblsz {
		width: 68rpx;
		height: 36rpx;
		border: 2rpx solid #4b9cff;
		border-radius: 6rpx;
		margin-left: 10rpx;
		padding: 0 10upx;
	}

	.bfh {
		font-size: 24rpx;
		margin-left: 15rpx;
	}
}

.ckqb {
	display: flex;
	justify-content: center;
	align-items: center;
	font-size: 26rpx;
	color: #ff8f28;
	margin-top: 30rpx;
}

.xhx {
	width: 100%;
	height: 2rpx;
	background-color: #dadfed;
	margin-top: 34rpx;
}

.scxy {
	display: flex;
	align-items: center;
	width: 190rpx;
	height: 52rpx;
	border: 2rpx solid #ab61ff;
	border-radius: 26rpx;
	color: #ab61ff;
	font-size: 26rpx;

	image {
		width: 30rpx;
		height: 30rpx;
		margin-top: 5rpx;
		margin-left: 26rpx;
	}
}

.tdxy {
	width: 690rpx;
	height: 159rpx;
	background: #f5f5f9;
	border-radius: 20rpx;

	.word {
		display: flex;
		align-items: center;

		image {
			width: 41rpx;
			height: 37rpx;
		}

		text {
			color: #4b9cff;
			font-size: 30rpx;
			margin-left: 16rpx;
		}
	}
}

.scsj {
	color: #0d1d36;
	font-size: 26rpx;
}

.sctime {
	display: flex;
	align-items: center;
	color: #888d99;
	font-size: 30rpx;
	margin-left: 20rpx;
}

.ty {
	width: 18rpx;
	height: 18rpx;
	background: #888d99;
	border-radius: 50%;
}

.xmjz {
	color: #888d99;
	font-size: 30rpx;
	margin-left: 20rpx;
}

.xx {
	width: 2rpx;
	height: 2rpx;
	border: 2rpx dashed #888d99;
	opacity: 0.5;
	margin-left: 7rpx;
}

.zxjz {
	color: #0d1d36;
	font-size: 30rpx;
	font-weight: bold;
	margin-left: 40rpx;
}

.tp {
	width: 192rpx;
	height: 192rpx;
	border-radius: 10rpx;
	background-color: #f5f5f9;
	margin-left: 30rpx;
	margin-top: 24rpx;
}

.tyqk {
	color: #0d1d36;
	font-size: 26rpx;
}

.hekuai {
	color: #ffffff;
	font-size: 26rpx;
	width: 72rpx;
	height: 32rpx;
	background: #4f5a78;
	border-radius: 4rpx;
	text-align: center;
	line-height: 32rpx;
	margin-left: 22rpx;
}

.sd {
	width: 48rpx;
	height: 48rpx;
}

.word {
	display: flex;
	align-items: center;

	image {
		width: 41rpx;
		height: 37rpx;
	}

	text {
		color: #4b9cff;
		font-size: 30rpx;
		margin-left: 16rpx;
	}
}

.qymc {
	width: 102rpx;
	height: 118rpx;
	background-repeat: no-repeat;
	background-size: 100% auto;
	background-position: 0 bottom;

	text {
		color: #888d99;
		font-size: 20rpx;
		line-height: 118rpx;
		margin-left: 8rpx;
	}
}

.bzj {
	position: absolute;
	left: 550rpx;
	font-size: 36rpx;
	color: #fe5022;
}

.caozuo {
	width: 690rpx;
	height: 124rpx;
	background-color: #f5f5f9;
	margin-top: -10rpx;

	.baocun {
		width: 160rpx;
		height: 64rpx;
		background: #4b9cff;
		border-radius: 10px;
		color: #ffffff;
		font-size: 30rpx;
		line-height: 64rpx;
	}

	.quxiao {
		width: 160rpx;
		height: 64rpx;
		background: #ffffff;
		border-radius: 10rpx;
		color: #888d99;
		font-size: 30rpx;
		line-height: 64rpx;
	}
}

.sc {
	display: flex;
	align-items: center;
	width: 136rpx;
	height: 52rpx;
	border: 2rpx solid #ab61ff;
	border-radius: 26rpx;
	color: #ab61ff;
	font-size: 26rpx;

	image {
		width: 30rpx;
		height: 30rpx;
		margin-top: 5rpx;
		margin-left: 26rpx;
	}
}

.qylg {
	width: 102rpx;
	height: 118rpx;
	background-size: 100% auto;
	background-position: 0 bottom;
	text-align: center;
	overflow: hidden;
	display: flex;
	justify-content: center;
	align-items: center;
	position: relative;
	text {
		color: #888d99;
		font-size: 26rpx;
		line-height: 25rpx;
		padding: 0 5rpx;
	}
	.tz {position: absolute;bottom:0;right:0;color:#fff;}
}

.f-list {
	border-bottom: 2rpx solid #dadfed;
}

.name {
	font-size: 28rpx;
	color: #4c9cff;
}

.tz {
	padding:0 5rpx;
	color: #ffffff;
	font-size: 24rpx;
	height: 36rpx;
	background: #ab61ff;
	border-radius: 6rpx;
	margin-left: 20rpx;
}
.td {
	padding:0 5rpx;
	color: #ffffff;
	font-size: 24rpx;
	height: 36rpx;
	background: #19C07D;
	border-radius: 6rpx;
	margin-left: 20rpx;
}

.xz {
	width: 114rpx;
	height: 50rpx;
	background: #4c9cff;
	border-radius: 25rpx;
	color: #ffffff;
	font-size: 26rpx;
	text-align: center;
	line-height: 50rpx;
	float: right;
}

.rq {
	font-size: 28rpx;
	color: #888e9a;
}

.wjdx {
	font-size: 28rpx;
	color: #888e9a;
	margin-left: 20rpx;
}

.scroll-view_H {
	white-space: nowrap;

	.scroll-view-item_H {
		display: inline-block;
		width: 100%;
		height: 100px;
	}

	.uni-bg-red {
		background: red;
	}

	.uni-bg-green {
		background: green;
	}

	.uni-bg-blue {
		background: blue;
	}
}
.swiper {
	height: 500rpx;
}
.team-bg {background-color: #fff;}
</style>
